<?php

namespace App\Kuafu\Mybank\Model;

use App\Kuafu\Base\Model\BaseModel;
use App\Kuafu\Base\Model\Traits\KfSoftDeletes;
use App\Kuafu\Base\Model\Traits\KfUid;
use App\Kuafu\Shop\Model\Shop;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasOne;

class MybankBillRecordBindModel extends BaseModel
{

    use HasFactory, KfSoftDeletes, KfUid;

    protected $connection = 'mysql';
    protected $table      = "mybank_bill_record_bind";

    protected $fillable = [
        'id',
        'billRecordId',
        'vostroBillId',
        'batchNo',
        'flagMark',
        'completeTime',
        'remark',
    ];
    const DEFAULT_FLAG_MARK = 0;
    const MATCH_FLAG_MARK   = 1;
    const ERR_FLAG_MARK     = 2;

    const MAPPING_FLAG_MARK = [
        self::DEFAULT_FLAG_MARK => '待分账',
        self::MATCH_FLAG_MARK   => '分账完成',
        self::ERR_FLAG_MARK     => '分账失败',
    ];

    /**
     * @return HasOne
     */
    public function billRecordRel(): HasOne
    {
        return $this->hasOne(MybankBillRecordModel::class, "id", "billRecordId");
    }

    /**
     * @return HasOne
     */
    public function vostroBillRel(): HasOne
    {
        return $this->hasOne(MybankVostroBillModel::class, "id", "vostroBillId");
    }

    /**
     * @return HasOne
     */
    public function entryInfoRel() :HasOne
    {
        return $this->hasOne(MybankEntryModel::class, 'merchantId', 'merchantId');
    }

}
